package com.oyjd.business.tab.activity;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import android.app.ActivityGroup;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.LinearLayout;

import com.oyjd.R;
import com.oyjd.framework.ui.tab.TabBar;
import com.oyjd.framework.ui.tab.TabVO;

/**
 * Tabs使用例子
 * 
 * @author 欧建东
 * @email oyjd@163.com
 * 
 */
@SuppressWarnings("deprecation")
public class TabsDemo extends ActivityGroup {
	private Random r = new Random();

	/** Called when the activity is first created. */

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 设置为无标题
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		TabBar tabs = new TabBar(this);
		setContentView(tabs);

		List<TabVO> data = new ArrayList<TabVO>();
		data.add(new TabVO(R.drawable.tab1blur, R.drawable.tab1, getView()));
		data.add(new TabVO(R.drawable.tab2blur, R.drawable.tab2, getView()));
		data.add(new TabVO(R.drawable.tab3blur, R.drawable.tab3, getView()));
		data.add(new TabVO(R.drawable.tab4blur, R.drawable.tab4, getView()));

		tabs.setTabData(data, 0);
	}

	private View getView() {
		int c = Color.rgb(r.nextInt(255), r.nextInt(255), r.nextInt(255));
		LinearLayout ll = new LinearLayout(this);
		ll.setBackgroundColor(c);
		return ll;
	}

}
